package ink.ykb.actDemo.taskListener;

import java.util.List;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.JavaDelegate;
import org.activiti.engine.delegate.TaskListener;
import org.activiti.engine.impl.el.FixedValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import ink.ykb.actDemo.dao.LeaveDao;
import ink.ykb.actDemo.dao.UserInfoDao;
import ink.ykb.actDemo.entity.Leave;
import ink.ykb.actDemo.entity.UserInfo;
import ink.ykb.actDemo.util.HttpRequestLocal;
import ink.ykb.actDemo.util.PlatformRuntimeException;
import ink.ykb.actDemo.util.bean.LeaveState;
import ink.ykb.actDemo.util.bean.PostType;

/**
 * 审批完成后更新请假申请状态
 * @author dell
 *
 */
@Service
@Transactional
public class LeaveFinishDelegateExpression implements JavaDelegate{

	@Autowired
	private HttpRequestLocal httpRequestLocal;
	@Autowired
	private UserInfoDao userInfoDao;
	@Autowired
	private LeaveDao leaveDao;
	

	@Override
	public void execute(DelegateExecution execution) {
		//TODO 如何获取leave的id？
		Integer leaveId = (Integer)execution.getVariable("leaveId");
		Leave leave = leaveDao.single(leaveId);
		leave.setState(LeaveState.PASS.getId());
		leaveDao.updateById(leave);
	}

}
